package com.miyake.server;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import com.miyake.client.datamanage.Parameter;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class DsParameter {
	@PrimaryKey 
	@Persistent(valueStrategy=IdGeneratorStrategy.IDENTITY)  
	private Key key;
	
	@Persistent
	private String id;

	@Persistent
	private String title;
	
	@Persistent
	private String value;

	@Persistent
	private String unit;


	public DsParameter(String id, String title, String value, String unit) {
		super();
		this.id = id;
		this.title = title;
		this.value = value;
		this.unit = unit;
	}

	public String getEncodedKey() {
		return KeyFactory.keyToString(key);
	}
	


	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public void setUnit(String unit) {
		this.unit = unit;
	}

	public String getUnit() {
		return unit;
	}
	
	public Parameter toRemoteObject() {
		Parameter ret = new Parameter(title, value, unit);
		return ret;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getTitle() {
		return title;
	}

}
